from tkinter import Tk, Label, Button
from tkinter.filedialog import askopenfilename
from PIL import Image, ImageTk


def open_image():
    global img_label
    file_path = askopenfilename(filetypes=[("Image Files", "*.png;*.jpg;*.jpeg;*.bmp")])
    if file_path:
        image = Image.open(file_path)
        photo = ImageTk.PhotoImage(image)
        img_label.config(image=photo)
        img_label.image = photo  # 防止图片被垃圾回收


root = Tk()

btn = Button(root, text="打开图片", command=open_image)
btn.pack()

img_label = Label(root)
img_label.pack()

root.mainloop()